#{extends 'main.html' /}
#{set title:entity ? entity.id : 'Create New Aircraft' /}

#{form @controllers.Aircraft.save()}

<input class="btn btn-primary" type="submit" name="save" value="Save" />
#{if entity}
<a href="@{controllers.Bind.aircraft(entity.aircraft_id)}" role="button" class="btn btn-primary">Select Split Templates</a>
<a class="btn btn-primary btn-success" href="@{Aircraft.edit()}" role="button">Create New Aircraft</a>
<input class="btn btn-danger" type="submit" name="delete" value="Delete" />
#{/if}

<p></p>
<input type="hidden" name="id" value="${entity ? entity.getId() : ''}" />

<div class="form-group col-md-6">
    <label for="aircraft_id" class="text-capitalize">aircraft ids</label>
    <textarea class="form-control" name="aircraft_id" id="aircraft_id"  rows="5">${entity ? entity.getId() : aircraft_id}</textarea>
</div>
<div class="form-group col-md-4">
    <label for="aircraft_type" class="text-capitalize">aircraft type</label>
    <select class="form-control" name="aircraft_type" id="aircraft_type">
        #{list items:allAircraftTypes, as:"item" }
            #{if entity}
                <H1>1</H1>
                #{set acType: entity.aircraft_type ? entity.aircraft_type.aircraft_type : '' /}
                #{if item.aircraft_type == acType }
                    <H1>2</H1>
                    <option value ="${item.aircraft_type}" selected>${item.aircraft_type}</option>
                #{else}
                    <H1>3</H1>
                    <option value ="${item.aircraft_type}">${item.aircraft_type}</option>
                #{/else}
                #{/if}
            #{/if}
            #{if !entity}
                <option value ="${item.aircraft_type}">${item.aircraft_type}</option>
            #{/if}
        #{/list}
    </select>
</div>
<div class="form-group col-md-4">
    <label for="airlines" class="text-capitalize">airlines</label>
    <select class="form-control" name="airlines" id="airlines">
        #{list items:allAirlines, as:"item" }
            #{set text: item.code2 + ' (' + item.name + ')'/}
            #{if entity}
                #{set airlinesId: entity.airlines ? entity.airlines.id : '' /}
                #{if item.id == airlinesId }
                    <option value ="${item.code2}" selected>${text}</option>
                    #{else}
                        <option value ="${item.code2}">${text}</option>
                    #{/else}
                #{/if}
            #{/if}
            #{if !entity }
                <option value ="${item.code2}">${text}</option>
            #{/if}
        #{/list}
    </select>
</div>

<p></p>

#{if entity}
#{ta014_table items:entity.split_templates /}
#{/if}


#{/form}

